import request from '@/utils/request';

// 流程管理-流程设计 分页查询
export function pageTbProcessDesign(params, data) {
  return request({
    url: '/web/erp/process/tbProcessDesign/page',
    method: 'post',
    params,
    data,
    hmacReq: true,
    encryptReq: true,
    decryptRes: true,
  });
}

// 流程管理-流程设计 查询详情
export function getTbProcessDesignInfo(id) {
  return request({
    url: '/web/erp/process/tbProcessDesign/info/' + id,
    method: 'get',
    decryptRes: true,
  });
}

// 流程管理-流程设计 新增
export function addTbProcessDesign(data) {
  return request({
    url: '/web/erp/process/tbProcessDesign/add',
    method: 'post',
    data,
    hmacReq: true,
    encryptReq: true,
    decryptRes: true,
  });
}

// 流程管理-流程设计 修改
export function updateTbProcessDesign(data) {
  return request({
    url: '/web/erp/process/tbProcessDesign/edit',
    method: 'post',
    data,
    hmacReq: true,
    encryptReq: true,
    decryptRes: true,
  });
}

// 流程管理-流程设计 删除
export function delTbProcessDesign(ids) {
  return request({
    url: '/web/erp/process/tbProcessDesign/delete/' + ids,
    method: 'post',
  });
}

// 流程管理-流程设计 导入模板
export function tplTbProcessDesign() {
  return request({
    url: '/web/erp/process/tbProcessDesign/template',
    method: 'post',
    responseType: 'blob',
    filename: `流程设计模版_${new Date().getTime()}.xlsx`,
  });
}

// 流程管理-流程设计 导出
export function exportTbProcessDesign(params, data) {
  return request({
    url: '/web/erp/process/tbProcessDesign/export',
    method: 'post',
    params,
    data,
    responseType: 'blob',
    filename: `流程设计_${new Date().getTime()}.xlsx`,
    hmacReq: true,
    encryptReq: true,
  });
}

// 根据id查询对应流程图
export function flowChart(id) {
  return request({
    url: '/web/erp/process/tbProcessDesign/enabledContent/' + id,
    method: 'get',
    decryptRes: true,
  });
}

// 保存流程图
export function savFlowChart(data) {
  return request({
    url: '/web/erp/process/tbProcessDesign/content/add',
    method: 'post',
    data,
    hmacReq: true,
    encryptReq: true,
    decryptRes: true,
  });
}

// 启用流程图
export function openFlowChart(id) {
  return request({
    url: '/web/erp/process/tbProcessDesign/content/enable/' + id,
    method: 'get',
    decryptRes: true,
  });
}

// 流程图列表
export function flowChartList(id, page) {
  return request({
    url: '/web/erp/process/tbProcessDesign/content/page/' + id,
    method: 'get',
    decryptRes: true,
    params: page,
  });
}

// 查询流程图详情
export function flowChartDetail(id) {
  return request({
    url: '/web/erp/process/tbProcessDesign/content/' + id,
    method: 'get',
    decryptRes: true,
  });
}

// 查询不可用的表单类型
export function disabledFlowType() {
  return request({
    url: '/web/erp/process/tbProcessDesign/type/unavailable',
    method: 'get',
    decryptRes: true,
  });
}

// 单据类型
export function businessTypeData() {
  return request({
    url: '/web/erp/process/businessTypes',
    method: 'get',
    hmacReq: true,
    encryptReq: true,
    decryptRes: true,
  });
}
